﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<html>
<body class="no-skin">
<!-- PAGE CONTENT BEGINS -->
    <table width="100%" border="0">
        <tr>
            <td width="9%" align="right" nowrap="nowrap"><strong>岗位名称：</strong>
                <input type="hidden" id="orgCode" value="${orgCode}">
            </td>
            <td width="22%">
                <input name="positionName" type="text" id="positionName" maxlength="100"/></td>
            <td width="39%">
                <button class="btn btn-sm btn-info" type="button" onclick="initTable();">
                    <i class="ace-icon glyphicon glyphicon-search bigger-110"></i>查 询
                </button>
                <button class="btn btn-sm btn-warning" type="button" onclick="toAddPos();">
                    <i class="ace-icon glyphicon glyphicon-plus bigger-110"></i>新 增
                </button>
            </td>
        </tr>
    </table>
    <!--查询区域end-->
    <div id="faq-tab-1" class="tab-pane fade in active">
        <!--查询结果-->
        <div style="overflow-x:auto;  margin-top:10px">
            <table id="pos_list_table" class="table table-striped table-bordered table-hover" style="margin:0; ">
                <caption></caption>
                <thead>
                <tr>
                    <th nowrap="nowrap" class="center"> 序号</th>
                    <th nowrap="nowrap"> 岗位名称</th>
                    <th nowrap="nowrap">岗位代码</th>
                    <th nowrap="nowrap">描述</th>
                    <th nowrap="nowrap">操作</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
    <script type="text/javascript">
        jQuery(function ($) {
            initTable();
        });
        function initTable() {
            $("#pos_list_table").dataTable().fnDestroy();
            json = {};
            json.showLineNuber = true;
            json.id = "pos_list_table";
            json.url = contextPath + '/auth/position/getPosListData.json';
            json.param = [{"name": "orgCode", "value": $("#orgCode").val()},
                {"name": "positionName", "value": $.trim($("#positionName").val())}
            ];
            json.columns = [{"sWidth": "20px", "sClass": "text-center"},
                {"mData": "positionName", "sWidth": "100px", "sClass": "text-center"},
                {"mData": "positionCode", "sWidth": "100px", "sClass": "text-center"},
                {"mData": "remark", "sWidth": "100px", "sClass": "text-center"},
                {
                    "mData": "positionId", "sWidth": "100px", "sClass": "text-center",
                    "mRender": function (data, type, row) {
                        if (data) {
                            return '&nbsp;&nbsp;<a style="color:#428bca" href="javascript:toEditPos(' + data + ')" >修改</a>&nbsp;&nbsp;<a style="color:#428bca" href="javascript:toDeletePos(' + data + ')" >删除</a>&nbsp;&nbsp;';
                        }
                    }
                }
            ];
            var oTable1 = TableManaged(json).init();
        }

        function toAddPos() {
            var orgCode = $("#orgCode").val();
            window.location.href = contextPath + "/auth/position/toAddPos.htm?orgCode=" + orgCode;
        }

        function toEditPos(posId) {
            window.location.href = contextPath + "/auth/position/toEditPosition.htm?positionId=" + posId;
        }

        function toDeletePos(posId) {
            $.Confirm('请确认是否删除该岗位？', '', function () {
                deletePos(posId);
            });
        }

        function deletePos(posId) {
            $.ajax({
                url: contextPath + "/auth/position/deletePosition.json",
                type: "post",
                data: {positionId: posId},
                async: false,
                success: function (data) {
                    var msg = eval("(" + data + ")");
                    if (msg.code == 1) {
                        $.Alert(msg.message, '', toPosList);
                    } else {
                        $.Alert(msg.message);
                    }
                },
                error: function () {
                    //$.Alert("服务异常，请稍后尝试！");
                }
            });
        }

        function toPosList() {
            var orgCode = $("#orgCode").val();
            location.href = contextPath + "/auth/position/toPosList.htm?orgCode=" + orgCode;
        }
    </script>
</body>
</html>
